package com.sk.bilibili.model.fragment.live;

import com.sk.api.annotations.Autowired;
import com.sk.bilibili.bean.History;
import com.sk.bilibili.callBack.RequestCallBack;
import com.sk.bilibili.dto.Page;
import com.sk.bilibili.mapper.HistoryMapper;
import com.sk.bilibili.model.BaseRefreshModel;
import com.sk.bilibili.other.JsonMap;
import com.sk.bilibili.utils.RequestUtils;
import com.sk.bilibili.view.fragment.live.HistoryFragment;
import com.sk.bilibili.view.fragment.live.RecommendFragment;

public class HistoryModel extends BaseRefreshModel<HistoryFragment> {

    @Autowired
    HistoryMapper historyMapper;
    private int page=1;
    private int size=10;

    @Override
    public void refreshData() {
        page=1;
        JsonMap map=getJsonMap();
        RequestUtils.process(historyMapper.pageSearch(map), historyPage -> {
            view.setData(historyPage.getRecords());
            page++;
        });
    }

    private JsonMap getJsonMap() {
        JsonMap map=new JsonMap();
        map.put("page",page);
        map.put("size",size);
        map.put("type",6);
        return map;
    }

    @Override
    public void loadData() {
        JsonMap map = getJsonMap();
        RequestUtils.process(historyMapper.pageSearch(map), historyPage -> {
            view.addData(historyPage.getRecords());
            page++;
        });
    }

}